﻿using System;
using System.IO;
using System.Windows.Forms;

namespace Z.IconLibraryGenerator.WinForm
{
    public partial class ApplicationConfiguration
    {
        /// <summary>Saves this object.</summary>
        public void Save()
        {
            try
            {
                string s = this.SerializeXml();
// ReSharper disable PossibleNullReferenceException
                Directory.CreateDirectory(ConfigurationConfigurationFilePath.ToFileInfo().Directory.FullName);
// ReSharper restore PossibleNullReferenceException
                s.SaveAs(ConfigurationConfigurationFilePath);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ErrorMessage.GeneralErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}